//
//  BTEProductTopTableViewCell.swift
//  BTE
//
//  Created by 张文 on 2025/8/31.
//

import UIKit

class BTEProductTopTableViewCell: UITableViewCell {
    
    var mod: BTEProductNetModel? {
        didSet {
            guard let m = mod else {
                return
            }
            
            a1.text = m.nonchurchgoing?.bakeboard
            a2.text = m.nonchurchgoing?.druggists
            
            a3.text = m.nonchurchgoing?.itching?.raffling?.subdichotomously
            a4.text = m.nonchurchgoing?.itching?.duller?.subdichotomously
        }
    }
    
    let bgimage = UIImageView.init(image: UIImage.init(named: "Group 11712769fewfewfwe03"))
    
    let a1 = UILabel()
    
    let a2 = UILabel()
    
    let a3 = UILabel()
    
    let a4 = UILabel()
    
    let buttonview = UIView()
    
    let tiel = UILabel()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        selectionStyle = .none
        backgroundColor = .clear
        
        contentView.backgroundColor = .clear
        
        contentView.addSubview(bgimage)
        
        bgimage.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview().offset(-16)
            make.top.equalToSuperview().offset(10)
            make.height.equalTo((UIScreen.main.bounds.width-32) * bgimage.frame.height / bgimage.frame.width)
        }

        a1.font = .systemFont(ofSize: 14, weight: .medium)
        a2.font = .systemFont(ofSize: 46, weight: .bold)
        a3.font = .systemFont(ofSize: 16, weight: .medium)
        a4.font = .systemFont(ofSize: 16, weight: .medium)
        
        [a1,a2,a3,a4].forEach { item in
            item.textColor = .black
            bgimage.addSubview(item)
        }
        
        a1.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(26)
            make.top.equalToSuperview().offset(26)
        }
        
        a2.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(26)
            make.top.equalTo(a1.snp.bottom).offset(16)
        }
        
        bgimage.addSubview(buttonview)
        buttonview.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-20)
        }
        
        
        let a1im = UIView()
        buttonview.addSubview(a1im)
        a1im.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let a1image = UIImageView.init(image: UIImage.init(named: "Group 1171276662fewfewfw33333"))
        a1im.addSubview(a1image)
        a1image.snp.makeConstraints { make in
            make.top.left.bottom.equalToSuperview()
            make.height.equalTo(30)
        }
        
        a1im.addSubview(a3)
        a3.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview()
            make.left.equalTo(a1image.snp.right).offset(12)
        }
        
        let a2im = UIView()
        buttonview.addSubview(a2im)
        a2im.snp.makeConstraints { make in
            make.right.equalToSuperview()
            make.top.bottom.equalToSuperview()
            make.left.equalTo(a1im.snp.right).offset(40)
        }
        
        let a2image = UIImageView.init(image: UIImage.init(named: "Group 117127ffeeeeww6885"))
        a2im.addSubview(a2image)
        a2image.snp.makeConstraints { make in
            make.top.left.bottom.equalToSuperview()
            make.height.equalTo(30)
            make.width.equalTo(30)
        }
        
        a2im.addSubview(a4)
        a4.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview()
            make.left.equalTo(a2image.snp.right).offset(12)
        }
        
        
        tiel.text = BTELanguageManager.shared.localizedString(forKey: "Certification conditions")
        tiel.font = .systemFont(ofSize: 18, weight: .bold)
        tiel.textColor = .black
        contentView.addSubview(tiel)
        tiel.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-18)
            make.centerX.equalToSuperview()
            make.top.equalTo(bgimage.snp.bottom).offset(18)
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
